import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MallProductVO, MallProductForm, MallProductQuery } from '@/api/mall/mallProduct/types';

/**
 * 查询商品列表
 * @param query
 * @returns {*}
 */

export const listMallProduct = (query?: MallProductQuery): AxiosPromise<MallProductVO[]> => {
  return request({
    url: '/mall/mallProduct/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品详细
 * @param id
 */
export const getMallProduct = (id: string | number): AxiosPromise<MallProductVO> => {
  return request({
    url: '/mall/mallProduct/' + id,
    method: 'get'
  });
};

/**
 * 新增商品
 * @param data
 */
export const addMallProduct = (data: MallProductForm) => {
  return request({
    url: '/mall/mallProduct',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品
 * @param data
 */
export const updateMallProduct = (data: MallProductForm) => {
  return request({
    url: '/mall/mallProduct',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品
 * @param id
 */
export const delMallProduct = (id: string | number | Array<string | number>) => {
  return request({
    url: '/mall/mallProduct/' + id,
    method: 'delete'
  });
};
